package edu.neu.swc.commerce.service.communication;

import edu.neu.swc.commerce.service.communication.hystrix.AuthorityFeignClientFallback;
import edu.neu.swc.commerce.service.communication.hystrix.AuthorityFeignClientFallbackFactory;
import edu.neu.swc.commerce.vo.JwtToken;
import edu.neu.swc.commerce.vo.UsernameAndPassword;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * <h1>与 Authority服务通信的feign Client接口定义</h1>
 */
@FeignClient(contextId = "AuthorityFeignClient", value = "e-commerce-authority-center",
            fallbackFactory = AuthorityFeignClientFallbackFactory.class)
public interface AuthorityFeignClient {


    /**
     * <h2>通过Open Feign 访问 Authority 获取 token</h2>
     */
    @RequestMapping(value = "/ecommerce-authority-center/authority/token",
        method = RequestMethod.POST,
        consumes = "application/json", produces = "application/json")
    JwtToken getTokenByFeign(@RequestBody UsernameAndPassword usernameAndPassword);
}
